using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Adex
{
	/// <summary>
	/// Strongly-typed collection for the SiteUser class.
	/// </summary>
	[Serializable]
	public partial class SiteUserCollection : ActiveList<SiteUser, SiteUserCollection> 
	{	   
		public SiteUserCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the SiteUser table.
	/// </summary>
	[Serializable]
	public partial class SiteUser : ActiveRecord<SiteUser>
	{
		#region .ctors and Default Settings
		
		public SiteUser()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public SiteUser(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

		public SiteUser(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public SiteUser(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor
		public static Query CreateQuery() { return new Query(Schema); }

		
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("SiteUser", TableType.Table, DataService.GetInstance("Adex"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarUserID = new TableSchema.TableColumn(schema);
				colvarUserID.ColumnName = "UserID";
				colvarUserID.DataType = DbType.Guid;
				colvarUserID.MaxLength = 0;
				colvarUserID.AutoIncrement = false;
				colvarUserID.IsNullable = false;
				colvarUserID.IsPrimaryKey = false;
				colvarUserID.IsForeignKey = true;
				colvarUserID.IsReadOnly = false;
				colvarUserID.DefaultSetting = @"";
				
					colvarUserID.ForeignKeyTableName = "aspnet_Users";
				schema.Columns.Add(colvarUserID);
				
				TableSchema.TableColumn colvarSiteUserID = new TableSchema.TableColumn(schema);
				colvarSiteUserID.ColumnName = "SiteUserID";
				colvarSiteUserID.DataType = DbType.Int32;
				colvarSiteUserID.MaxLength = 0;
				colvarSiteUserID.AutoIncrement = true;
				colvarSiteUserID.IsNullable = false;
				colvarSiteUserID.IsPrimaryKey = true;
				colvarSiteUserID.IsForeignKey = false;
				colvarSiteUserID.IsReadOnly = false;
				colvarSiteUserID.DefaultSetting = @"";
				colvarSiteUserID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSiteUserID);
				
				TableSchema.TableColumn colvarUserName = new TableSchema.TableColumn(schema);
				colvarUserName.ColumnName = "UserName";
				colvarUserName.DataType = DbType.String;
				colvarUserName.MaxLength = 50;
				colvarUserName.AutoIncrement = false;
				colvarUserName.IsNullable = true;
				colvarUserName.IsPrimaryKey = false;
				colvarUserName.IsForeignKey = false;
				colvarUserName.IsReadOnly = false;
				colvarUserName.DefaultSetting = @"";
				colvarUserName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarUserName);
				
				TableSchema.TableColumn colvarCountryID = new TableSchema.TableColumn(schema);
				colvarCountryID.ColumnName = "CountryID";
				colvarCountryID.DataType = DbType.Byte;
				colvarCountryID.MaxLength = 0;
				colvarCountryID.AutoIncrement = false;
				colvarCountryID.IsNullable = true;
				colvarCountryID.IsPrimaryKey = false;
				colvarCountryID.IsForeignKey = true;
				colvarCountryID.IsReadOnly = false;
				colvarCountryID.DefaultSetting = @"";
				
					colvarCountryID.ForeignKeyTableName = "Country";
				schema.Columns.Add(colvarCountryID);
				
				TableSchema.TableColumn colvarCompanyCode = new TableSchema.TableColumn(schema);
				colvarCompanyCode.ColumnName = "CompanyCode";
				colvarCompanyCode.DataType = DbType.Int32;
				colvarCompanyCode.MaxLength = 0;
				colvarCompanyCode.AutoIncrement = false;
				colvarCompanyCode.IsNullable = true;
				colvarCompanyCode.IsPrimaryKey = false;
				colvarCompanyCode.IsForeignKey = true;
				colvarCompanyCode.IsReadOnly = false;
				colvarCompanyCode.DefaultSetting = @"";
				
					colvarCompanyCode.ForeignKeyTableName = "Company";
				schema.Columns.Add(colvarCompanyCode);
				
				TableSchema.TableColumn colvarScreenName = new TableSchema.TableColumn(schema);
				colvarScreenName.ColumnName = "ScreenName";
				colvarScreenName.DataType = DbType.String;
				colvarScreenName.MaxLength = 50;
				colvarScreenName.AutoIncrement = false;
				colvarScreenName.IsNullable = true;
				colvarScreenName.IsPrimaryKey = false;
				colvarScreenName.IsForeignKey = false;
				colvarScreenName.IsReadOnly = false;
				colvarScreenName.DefaultSetting = @"";
				colvarScreenName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarScreenName);
				
				TableSchema.TableColumn colvarEmail = new TableSchema.TableColumn(schema);
				colvarEmail.ColumnName = "Email";
				colvarEmail.DataType = DbType.String;
				colvarEmail.MaxLength = 100;
				colvarEmail.AutoIncrement = false;
				colvarEmail.IsNullable = true;
				colvarEmail.IsPrimaryKey = false;
				colvarEmail.IsForeignKey = false;
				colvarEmail.IsReadOnly = false;
				colvarEmail.DefaultSetting = @"";
				colvarEmail.ForeignKeyTableName = "";
				schema.Columns.Add(colvarEmail);
				
				TableSchema.TableColumn colvarCell = new TableSchema.TableColumn(schema);
				colvarCell.ColumnName = "Cell";
				colvarCell.DataType = DbType.String;
				colvarCell.MaxLength = 20;
				colvarCell.AutoIncrement = false;
				colvarCell.IsNullable = true;
				colvarCell.IsPrimaryKey = false;
				colvarCell.IsForeignKey = false;
				colvarCell.IsReadOnly = false;
				colvarCell.DefaultSetting = @"";
				colvarCell.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCell);
				
				TableSchema.TableColumn colvarFullName = new TableSchema.TableColumn(schema);
				colvarFullName.ColumnName = "FullName";
				colvarFullName.DataType = DbType.String;
				colvarFullName.MaxLength = 100;
				colvarFullName.AutoIncrement = false;
				colvarFullName.IsNullable = true;
				colvarFullName.IsPrimaryKey = false;
				colvarFullName.IsForeignKey = false;
				colvarFullName.IsReadOnly = false;
				colvarFullName.DefaultSetting = @"";
				colvarFullName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarFullName);
				
				TableSchema.TableColumn colvarPhoto = new TableSchema.TableColumn(schema);
				colvarPhoto.ColumnName = "Photo";
				colvarPhoto.DataType = DbType.String;
				colvarPhoto.MaxLength = 50;
				colvarPhoto.AutoIncrement = false;
				colvarPhoto.IsNullable = false;
				colvarPhoto.IsPrimaryKey = false;
				colvarPhoto.IsForeignKey = false;
				colvarPhoto.IsReadOnly = false;
				
						colvarPhoto.DefaultSetting = @"(N'noimage.png')";
				colvarPhoto.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPhoto);
				
				TableSchema.TableColumn colvarUnlockCode = new TableSchema.TableColumn(schema);
				colvarUnlockCode.ColumnName = "UnlockCode";
				colvarUnlockCode.DataType = DbType.String;
				colvarUnlockCode.MaxLength = 6;
				colvarUnlockCode.AutoIncrement = false;
				colvarUnlockCode.IsNullable = true;
				colvarUnlockCode.IsPrimaryKey = false;
				colvarUnlockCode.IsForeignKey = false;
				colvarUnlockCode.IsReadOnly = false;
				colvarUnlockCode.DefaultSetting = @"";
				colvarUnlockCode.ForeignKeyTableName = "";
				schema.Columns.Add(colvarUnlockCode);
				
				TableSchema.TableColumn colvarActive = new TableSchema.TableColumn(schema);
				colvarActive.ColumnName = "Active";
				colvarActive.DataType = DbType.Boolean;
				colvarActive.MaxLength = 0;
				colvarActive.AutoIncrement = false;
				colvarActive.IsNullable = false;
				colvarActive.IsPrimaryKey = false;
				colvarActive.IsForeignKey = false;
				colvarActive.IsReadOnly = false;
				
						colvarActive.DefaultSetting = @"((0))";
				colvarActive.ForeignKeyTableName = "";
				schema.Columns.Add(colvarActive);
				
				TableSchema.TableColumn colvarValidFrom = new TableSchema.TableColumn(schema);
				colvarValidFrom.ColumnName = "ValidFrom";
				colvarValidFrom.DataType = DbType.DateTime;
				colvarValidFrom.MaxLength = 0;
				colvarValidFrom.AutoIncrement = false;
				colvarValidFrom.IsNullable = true;
				colvarValidFrom.IsPrimaryKey = false;
				colvarValidFrom.IsForeignKey = false;
				colvarValidFrom.IsReadOnly = false;
				colvarValidFrom.DefaultSetting = @"";
				colvarValidFrom.ForeignKeyTableName = "";
				schema.Columns.Add(colvarValidFrom);
				
				TableSchema.TableColumn colvarValidTo = new TableSchema.TableColumn(schema);
				colvarValidTo.ColumnName = "ValidTo";
				colvarValidTo.DataType = DbType.DateTime;
				colvarValidTo.MaxLength = 0;
				colvarValidTo.AutoIncrement = false;
				colvarValidTo.IsNullable = true;
				colvarValidTo.IsPrimaryKey = false;
				colvarValidTo.IsForeignKey = false;
				colvarValidTo.IsReadOnly = false;
				colvarValidTo.DefaultSetting = @"";
				colvarValidTo.ForeignKeyTableName = "";
				schema.Columns.Add(colvarValidTo);
				
				TableSchema.TableColumn colvarBalanceAmount = new TableSchema.TableColumn(schema);
				colvarBalanceAmount.ColumnName = "BalanceAmount";
				colvarBalanceAmount.DataType = DbType.Currency;
				colvarBalanceAmount.MaxLength = 0;
				colvarBalanceAmount.AutoIncrement = false;
				colvarBalanceAmount.IsNullable = false;
				colvarBalanceAmount.IsPrimaryKey = false;
				colvarBalanceAmount.IsForeignKey = false;
				colvarBalanceAmount.IsReadOnly = false;
				
						colvarBalanceAmount.DefaultSetting = @"((0))";
				colvarBalanceAmount.ForeignKeyTableName = "";
				schema.Columns.Add(colvarBalanceAmount);
				
				TableSchema.TableColumn colvarPromotionCode = new TableSchema.TableColumn(schema);
				colvarPromotionCode.ColumnName = "PromotionCode";
				colvarPromotionCode.DataType = DbType.String;
				colvarPromotionCode.MaxLength = 15;
				colvarPromotionCode.AutoIncrement = false;
				colvarPromotionCode.IsNullable = true;
				colvarPromotionCode.IsPrimaryKey = false;
				colvarPromotionCode.IsForeignKey = false;
				colvarPromotionCode.IsReadOnly = false;
				colvarPromotionCode.DefaultSetting = @"";
				colvarPromotionCode.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPromotionCode);
				
				TableSchema.TableColumn colvarReferralCode = new TableSchema.TableColumn(schema);
				colvarReferralCode.ColumnName = "ReferralCode";
				colvarReferralCode.DataType = DbType.String;
				colvarReferralCode.MaxLength = 15;
				colvarReferralCode.AutoIncrement = false;
				colvarReferralCode.IsNullable = true;
				colvarReferralCode.IsPrimaryKey = false;
				colvarReferralCode.IsForeignKey = false;
				colvarReferralCode.IsReadOnly = false;
				colvarReferralCode.DefaultSetting = @"";
				colvarReferralCode.ForeignKeyTableName = "";
				schema.Columns.Add(colvarReferralCode);
				
				TableSchema.TableColumn colvarReferralType = new TableSchema.TableColumn(schema);
				colvarReferralType.ColumnName = "ReferralType";
				colvarReferralType.DataType = DbType.AnsiStringFixedLength;
				colvarReferralType.MaxLength = 1;
				colvarReferralType.AutoIncrement = false;
				colvarReferralType.IsNullable = true;
				colvarReferralType.IsPrimaryKey = false;
				colvarReferralType.IsForeignKey = false;
				colvarReferralType.IsReadOnly = false;
				
						colvarReferralType.DefaultSetting = @"('P')";
				colvarReferralType.ForeignKeyTableName = "";
				schema.Columns.Add(colvarReferralType);
				
				TableSchema.TableColumn colvarRefUserId = new TableSchema.TableColumn(schema);
				colvarRefUserId.ColumnName = "RefUserId";
				colvarRefUserId.DataType = DbType.Int32;
				colvarRefUserId.MaxLength = 0;
				colvarRefUserId.AutoIncrement = false;
				colvarRefUserId.IsNullable = true;
				colvarRefUserId.IsPrimaryKey = false;
				colvarRefUserId.IsForeignKey = false;
				colvarRefUserId.IsReadOnly = false;
				colvarRefUserId.DefaultSetting = @"";
				colvarRefUserId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarRefUserId);
				
				TableSchema.TableColumn colvarDateAdded = new TableSchema.TableColumn(schema);
				colvarDateAdded.ColumnName = "DateAdded";
				colvarDateAdded.DataType = DbType.DateTime;
				colvarDateAdded.MaxLength = 0;
				colvarDateAdded.AutoIncrement = false;
				colvarDateAdded.IsNullable = false;
				colvarDateAdded.IsPrimaryKey = false;
				colvarDateAdded.IsForeignKey = false;
				colvarDateAdded.IsReadOnly = false;
				
						colvarDateAdded.DefaultSetting = @"(getdate())";
				colvarDateAdded.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDateAdded);
				
				TableSchema.TableColumn colvarDateModified = new TableSchema.TableColumn(schema);
				colvarDateModified.ColumnName = "DateModified";
				colvarDateModified.DataType = DbType.DateTime;
				colvarDateModified.MaxLength = 0;
				colvarDateModified.AutoIncrement = false;
				colvarDateModified.IsNullable = false;
				colvarDateModified.IsPrimaryKey = false;
				colvarDateModified.IsForeignKey = false;
				colvarDateModified.IsReadOnly = false;
				
						colvarDateModified.DefaultSetting = @"(getdate())";
				colvarDateModified.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDateModified);
				
				TableSchema.TableColumn colvarIsLoggedIn = new TableSchema.TableColumn(schema);
				colvarIsLoggedIn.ColumnName = "IsLoggedIn";
				colvarIsLoggedIn.DataType = DbType.Boolean;
				colvarIsLoggedIn.MaxLength = 0;
				colvarIsLoggedIn.AutoIncrement = false;
				colvarIsLoggedIn.IsNullable = true;
				colvarIsLoggedIn.IsPrimaryKey = false;
				colvarIsLoggedIn.IsForeignKey = false;
				colvarIsLoggedIn.IsReadOnly = false;
				colvarIsLoggedIn.DefaultSetting = @"";
				colvarIsLoggedIn.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsLoggedIn);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["Adex"].AddSchema("SiteUser",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("UserID")]
		public Guid UserID 
		{
			get { return GetColumnValue<Guid>("UserID"); }

			set { SetColumnValue("UserID", value); }

		}

		  
		[XmlAttribute("SiteUserID")]
		public int SiteUserID 
		{
			get { return GetColumnValue<int>("SiteUserID"); }

			set { SetColumnValue("SiteUserID", value); }

		}

		  
		[XmlAttribute("UserName")]
		public string UserName 
		{
			get { return GetColumnValue<string>("UserName"); }

			set { SetColumnValue("UserName", value); }

		}

		  
		[XmlAttribute("CountryID")]
		public byte? CountryID 
		{
			get { return GetColumnValue<byte?>("CountryID"); }

			set { SetColumnValue("CountryID", value); }

		}

		  
		[XmlAttribute("CompanyCode")]
		public int? CompanyCode 
		{
			get { return GetColumnValue<int?>("CompanyCode"); }

			set { SetColumnValue("CompanyCode", value); }

		}

		  
		[XmlAttribute("ScreenName")]
		public string ScreenName 
		{
			get { return GetColumnValue<string>("ScreenName"); }

			set { SetColumnValue("ScreenName", value); }

		}

		  
		[XmlAttribute("Email")]
		public string Email 
		{
			get { return GetColumnValue<string>("Email"); }

			set { SetColumnValue("Email", value); }

		}

		  
		[XmlAttribute("Cell")]
		public string Cell 
		{
			get { return GetColumnValue<string>("Cell"); }

			set { SetColumnValue("Cell", value); }

		}

		  
		[XmlAttribute("FullName")]
		public string FullName 
		{
			get { return GetColumnValue<string>("FullName"); }

			set { SetColumnValue("FullName", value); }

		}

		  
		[XmlAttribute("Photo")]
		public string Photo 
		{
			get { return GetColumnValue<string>("Photo"); }

			set { SetColumnValue("Photo", value); }

		}

		  
		[XmlAttribute("UnlockCode")]
		public string UnlockCode 
		{
			get { return GetColumnValue<string>("UnlockCode"); }

			set { SetColumnValue("UnlockCode", value); }

		}

		  
		[XmlAttribute("Active")]
		public bool Active 
		{
			get { return GetColumnValue<bool>("Active"); }

			set { SetColumnValue("Active", value); }

		}

		  
		[XmlAttribute("ValidFrom")]
		public DateTime? ValidFrom 
		{
			get { return GetColumnValue<DateTime?>("ValidFrom"); }

			set { SetColumnValue("ValidFrom", value); }

		}

		  
		[XmlAttribute("ValidTo")]
		public DateTime? ValidTo 
		{
			get { return GetColumnValue<DateTime?>("ValidTo"); }

			set { SetColumnValue("ValidTo", value); }

		}

		  
		[XmlAttribute("BalanceAmount")]
		public decimal BalanceAmount 
		{
			get { return GetColumnValue<decimal>("BalanceAmount"); }

			set { SetColumnValue("BalanceAmount", value); }

		}

		  
		[XmlAttribute("PromotionCode")]
		public string PromotionCode 
		{
			get { return GetColumnValue<string>("PromotionCode"); }

			set { SetColumnValue("PromotionCode", value); }

		}

		  
		[XmlAttribute("ReferralCode")]
		public string ReferralCode 
		{
			get { return GetColumnValue<string>("ReferralCode"); }

			set { SetColumnValue("ReferralCode", value); }

		}

		  
		[XmlAttribute("ReferralType")]
		public string ReferralType 
		{
			get { return GetColumnValue<string>("ReferralType"); }

			set { SetColumnValue("ReferralType", value); }

		}

		  
		[XmlAttribute("RefUserId")]
		public int? RefUserId 
		{
			get { return GetColumnValue<int?>("RefUserId"); }

			set { SetColumnValue("RefUserId", value); }

		}

		  
		[XmlAttribute("DateAdded")]
		public DateTime DateAdded 
		{
			get { return GetColumnValue<DateTime>("DateAdded"); }

			set { SetColumnValue("DateAdded", value); }

		}

		  
		[XmlAttribute("DateModified")]
		public DateTime DateModified 
		{
			get { return GetColumnValue<DateTime>("DateModified"); }

			set { SetColumnValue("DateModified", value); }

		}

		  
		[XmlAttribute("IsLoggedIn")]
		public bool? IsLoggedIn 
		{
			get { return GetColumnValue<bool?>("IsLoggedIn"); }

			set { SetColumnValue("IsLoggedIn", value); }

		}

		
		#endregion
		
		
		#region PrimaryKey Methods
		
		public Adex.OrderCollection OrderRecords()
		{
			return new Adex.OrderCollection().Where(Order.Columns.SiteUserID, SiteUserID).Load();
		}

		public Adex.UserModuleCollection UserModuleRecords()
		{
			return new Adex.UserModuleCollection().Where(UserModule.Columns.UserID, SiteUserID).Load();
		}

		#endregion
		
			
		
		#region ForeignKey Properties
		
		/// <summary>
		/// Returns a AspnetUser ActiveRecord object related to this SiteUser
		/// 
		/// </summary>
		public Adex.AspnetUser AspnetUser
		{
			get { return Adex.AspnetUser.FetchByID(this.UserID); }

			set { SetColumnValue("UserID", value.UserId); }

		}

		
		
		/// <summary>
		/// Returns a Company ActiveRecord object related to this SiteUser
		/// 
		/// </summary>
		public Adex.Company Company
		{
			get { return Adex.Company.FetchByID(this.CompanyCode); }

			set { SetColumnValue("CompanyCode", value.CompanyCode); }

		}

		
		
		/// <summary>
		/// Returns a Country ActiveRecord object related to this SiteUser
		/// 
		/// </summary>
		public Adex.Country Country
		{
			get { return Adex.Country.FetchByID(this.CountryID); }

			set { SetColumnValue("CountryID", value.CountryID); }

		}

		
		
		#endregion
		
		
		
		//no ManyToMany tables defined (0)
		
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(Guid varUserID,string varUserName,byte? varCountryID,int? varCompanyCode,string varScreenName,string varEmail,string varCell,string varFullName,string varPhoto,string varUnlockCode,bool varActive,DateTime? varValidFrom,DateTime? varValidTo,decimal varBalanceAmount,string varPromotionCode,string varReferralCode,string varReferralType,int? varRefUserId,DateTime varDateAdded,DateTime varDateModified,bool? varIsLoggedIn)
		{
			SiteUser item = new SiteUser();
			
			item.UserID = varUserID;
			
			item.UserName = varUserName;
			
			item.CountryID = varCountryID;
			
			item.CompanyCode = varCompanyCode;
			
			item.ScreenName = varScreenName;
			
			item.Email = varEmail;
			
			item.Cell = varCell;
			
			item.FullName = varFullName;
			
			item.Photo = varPhoto;
			
			item.UnlockCode = varUnlockCode;
			
			item.Active = varActive;
			
			item.ValidFrom = varValidFrom;
			
			item.ValidTo = varValidTo;
			
			item.BalanceAmount = varBalanceAmount;
			
			item.PromotionCode = varPromotionCode;
			
			item.ReferralCode = varReferralCode;
			
			item.ReferralType = varReferralType;
			
			item.RefUserId = varRefUserId;
			
			item.DateAdded = varDateAdded;
			
			item.DateModified = varDateModified;
			
			item.IsLoggedIn = varIsLoggedIn;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(Guid varUserID,int varSiteUserID,string varUserName,byte? varCountryID,int? varCompanyCode,string varScreenName,string varEmail,string varCell,string varFullName,string varPhoto,string varUnlockCode,bool varActive,DateTime? varValidFrom,DateTime? varValidTo,decimal varBalanceAmount,string varPromotionCode,string varReferralCode,string varReferralType,int? varRefUserId,DateTime varDateAdded,DateTime varDateModified,bool? varIsLoggedIn)
		{
			SiteUser item = new SiteUser();
			
				item.UserID = varUserID;
				
				item.SiteUserID = varSiteUserID;
				
				item.UserName = varUserName;
				
				item.CountryID = varCountryID;
				
				item.CompanyCode = varCompanyCode;
				
				item.ScreenName = varScreenName;
				
				item.Email = varEmail;
				
				item.Cell = varCell;
				
				item.FullName = varFullName;
				
				item.Photo = varPhoto;
				
				item.UnlockCode = varUnlockCode;
				
				item.Active = varActive;
				
				item.ValidFrom = varValidFrom;
				
				item.ValidTo = varValidTo;
				
				item.BalanceAmount = varBalanceAmount;
				
				item.PromotionCode = varPromotionCode;
				
				item.ReferralCode = varReferralCode;
				
				item.ReferralType = varReferralType;
				
				item.RefUserId = varRefUserId;
				
				item.DateAdded = varDateAdded;
				
				item.DateModified = varDateModified;
				
				item.IsLoggedIn = varIsLoggedIn;
				
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string UserID = @"UserID";
			 public static string SiteUserID = @"SiteUserID";
			 public static string UserName = @"UserName";
			 public static string CountryID = @"CountryID";
			 public static string CompanyCode = @"CompanyCode";
			 public static string ScreenName = @"ScreenName";
			 public static string Email = @"Email";
			 public static string Cell = @"Cell";
			 public static string FullName = @"FullName";
			 public static string Photo = @"Photo";
			 public static string UnlockCode = @"UnlockCode";
			 public static string Active = @"Active";
			 public static string ValidFrom = @"ValidFrom";
			 public static string ValidTo = @"ValidTo";
			 public static string BalanceAmount = @"BalanceAmount";
			 public static string PromotionCode = @"PromotionCode";
			 public static string ReferralCode = @"ReferralCode";
			 public static string ReferralType = @"ReferralType";
			 public static string RefUserId = @"RefUserId";
			 public static string DateAdded = @"DateAdded";
			 public static string DateModified = @"DateModified";
			 public static string IsLoggedIn = @"IsLoggedIn";
						
		}

		#endregion
	}

}

